<template>
  <div class="app-container">
    <!-- 顶部控制台 -->
    <div class="filter-container">
      <el-input class="filter-item" style="width: 200px; margin-left: 0px" size="mini" placeholder="图片名称" v-model="form.searchTitle"/>
      <el-select class="filter-item" style="width: 160px" size="mini" v-model="form.searchType" @change="handlePageInit">
        <el-option v-for="item in pageData.searchTypeList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchStatus" @change="handlePageInit">
        <el-option v-for="item in pageData.searchStatusList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-select class="filter-item" style="width: 120px" size="mini" v-model="form.searchJumpType" @change="handlePageInit">
        <el-option v-for="item in pageData.searchJumpTypeList" :key="item.value" :label="item.label" :value="item.value"/>
      </el-select>
      <el-button type="primary" size="mini" icon="el-icon-search" @click="handlePageInit">搜索</el-button>
      <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleOpenSavePage">新增</el-button>
      <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleSaveBannerGroupButtonClick">新增开机图组</el-button>
      <el-button type="success" size="mini" icon="el-icon-share" @click="handleBatchReleaseData" :disabled="form.selection.length < 1">批量发布</el-button>
    </div>
    <!--数据列表-->
    <div class="data-table">
      <el-table :data="responseData.tableList"
                border style="width: 100%;"
                v-loading="pageData.loading"
                element-loading-text="拼命加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.8)"
                :header-cell-style="{ background: '#545C64', color: '#ffffff' }"
                @selection-change="handleTableSelection">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column fixed="left" prop="id" label="数据ID" width="120" align="center"></el-table-column>
        <el-table-column prop="bannerName" label="图片名称" width="160" align="center"></el-table-column>
        <el-table-column prop="bannerType" label="所属板块" width="200" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerType === 1"><el-tag type="warning">首页版块轮播图</el-tag></span>
            <span v-if="scope.row.bannerType === 2"><el-tag type="success">案例点评版块轮播图</el-tag></span>
            <span v-if="scope.row.bannerType === 3"><el-tag type="primary">视频课堂版块轮播图</el-tag></span>
            <span v-if="scope.row.bannerType === 4"><el-tag type="info">研修直播版块直播广告图</el-tag></span>
            <span v-if="scope.row.bannerType === 5"><el-tag type="danger">问答版块轮播图</el-tag></span>
            <span v-if="scope.row.bannerType === 6"><el-tag type="danger">发现版块轮播图</el-tag></span>
            <span v-if="scope.row.bannerType === 9"><el-tag type="info">APP开机图</el-tag></span>
            <span v-if="scope.row.bannerType === 21"><el-tag type="success">报名专属</el-tag></span>
            <span v-if="scope.row.bannerType === 88"><el-tag type="primary">滑动块广告</el-tag></span>
            <span v-if="scope.row.bannerType === 99"><el-tag type="success">单图广告</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerImageType" label="图像类型" width="100" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerImageType === 0"><el-tag type="warning">图片</el-tag></span>
            <span v-if="scope.row.bannerImageType === 1"><el-tag type="success">GIF</el-tag></span>
            <span v-if="scope.row.bannerImageType === 2"><el-tag type="primary">视频</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerIsOutLink" label="是否外链" width="100" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerIsOutLink === 0"><el-tag type="warning">非外链</el-tag></span>
            <span v-if="scope.row.bannerIsOutLink === 1"><el-tag type="success">外链</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerIsSubject" label="跳转类型" width="120" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerIsSubject === 0"><el-tag type="warning">广告</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 1"><el-tag type="success">单体内容</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 2"><el-tag type="primary">成套内容</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 3"><el-tag type="info">专题</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 4"><el-tag type="danger">问答</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 5"><el-tag type="warning">活动</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 6"><el-tag type="success">在线课程</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 7"><el-tag type="primary">在线报名</el-tag></span>
            <span v-if="scope.row.bannerIsSubject === 8"><el-tag type="info">小程序跳转</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerStatus" label="审核状态" width="100" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerStatus === 0"><el-tag type="warning">下架</el-tag></span>
            <span v-if="scope.row.bannerStatus === 1"><el-tag type="success">发布</el-tag></span>
            <span v-if="scope.row.bannerStatus === 2"><el-tag type="danger">删除</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerImage" label="ICON图" width="120" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerImage != null && scope.row.bannerImage !== ''">
              <el-button size="small" width="120" type="success" @click="handleCheckInfo(scope.row.bannerImage)">预览</el-button>
            </span>
            <span v-else >无</span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerArticleId" label="内链地址" width="320" align="center"></el-table-column>
        <el-table-column prop="bannerJumpUrl" label="外链地址" width="320" align="center"></el-table-column>
        <el-table-column prop="bannerInfo" label="图像简介" width="320" align="center"></el-table-column>
        <el-table-column prop="bannerPicture" label="分享图" width="120" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.bannerPicture != null && scope.row.bannerPicture !== ''">
              <el-button size="small" width="120" type="success" @click="handleCheckInfo(scope.row.bannerPicture)">预览</el-button>
            </span>
            <span v-else >无</span>
          </template>
        </el-table-column>
        <el-table-column prop="bannerSignUpId" label="研修班" width="120" align="center"></el-table-column>
        <el-table-column prop="bannerImageDuration" label="视频时长" width="120" align="center"></el-table-column>
        <el-table-column fixed="right" label="操作" width="240" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="handleOpenEditPage(scope)">编辑</el-button>
            <el-button v-if="scope.row.bannerStatus === 0" type="success" size="small" @click="handleUpdateDataStatus(scope, 1)">发布</el-button>
            <el-button v-if="scope.row.bannerStatus === 1" type="warning" size="small" @click="handleUpdateDataStatus(scope, 0)">下架</el-button>
            <el-button type="danger" size="small" @click="handleDeleteData(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页器-->
    <div style="margin-top: 20px">
      <div class="block" style="width: 100%; text-align: center">
        <el-pagination
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="form.pageNum"
          :page-size="form.pageSize"
          :total="form.total"
          :page-sizes="[12, 50, 100, 200]"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange">
        </el-pagination>
      </div>
    </div>
    <!--新增隐藏域-->
    <el-dialog :title="pageData.savePanelTitle" :visible.sync="pageData.savePanelStatus" size="small"
               :before-close="handleCloseSavePage">
      <el-form ref="form.banner" :model="form.banner" label-width="120">
        <el-row :gutter="0">
          <el-col :span="12">
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="名称"><el-input v-model="form.banner.bannerName" size="mini" style="width: 200px"/></el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="板块">
                  <el-select v-model="form.banner.bannerType" size="mini">
                    <el-option v-for="item in pageData.bannerTypeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="类型">
                  <el-radio v-model="form.banner.bannerImageType" :label="0">图像</el-radio>
                  <el-radio v-model="form.banner.bannerImageType" :label="1">GIF</el-radio>
                  <el-radio v-model="form.banner.bannerImageType" :label="2">视频</el-radio>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="外链">
                  <el-radio v-model="form.banner.bannerIsOutLink" :label="1">是</el-radio>
                  <el-radio v-model="form.banner.bannerIsOutLink" :label="0">否</el-radio>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="跳转">
                  <el-select v-model="form.banner.bannerIsSubject" size="mini">
                    <el-option v-for="item in pageData.bannerIsSubjectList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="状态">
                  <el-radio v-model="form.banner.bannerStatus" :label="0">下架</el-radio>
                  <el-radio v-model="form.banner.bannerStatus" :label="1">发布</el-radio>
                  <el-tag type="info">直接发布与开始时间无关</el-tag>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row :gutter="0">
              <el-col :span="24">
                <el-form-item label="ICON图">
                  <el-upload
                    class="avatar-uploader"
                    action="/api/cms/common/uploadFile"
                    :show-file-list="false"
                    :on-success="handleBannerImageUploadSuccess">
                    <img v-if="form.banner.bannerImage" :src="form.banner.bannerImage" class="avatar">
                    <i v-else class="el-icon-plus avatar-uploader-icon" style="line-height: 178px"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="分享图">
                  <el-upload
                    class="avatar-uploader"
                    action="/api/cms/common/uploadFile"
                    :show-file-list="false"
                    :on-success="handleBannerPictureUploadSuccess">
                    <img v-if="form.banner.bannerPicture" :src="form.banner.bannerPicture" class="avatar">
                    <i v-else class="el-icon-plus avatar-uploader-icon" style="line-height: 178px"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
        <el-row :gutter="0" v-if="form.banner.bannerType == 9">
          <el-col :span="12">
            <el-form-item label="开始时间">
              <el-date-picker v-model="form.banner.startTime" type="datetime" placeholder="选择日期时间" size="mini"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间">
              <el-date-picker v-model="form.banner.endTime" type="datetime" placeholder="选择日期时间" size="mini"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="内链ID">
              <el-input v-model="form.banner.bannerArticleId" size="mini" style="width: 200px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="外链ID">
              <el-input v-model="form.banner.bannerJumpUrl" size="mini" style="width: 200px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span="12">
            <el-form-item label="视频时长">
              <el-input v-model="form.banner.bannerImageDuration" size="mini" style="width: 200px"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="研修班">
              <el-input v-model="form.banner.bannerSignUpId" size="mini" style="width: 200px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span="24">
            <el-form-item label="图像简介">
              <el-input v-model="form.banner.bannerInfo" type="textarea" size="mini" style="width: 600px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span="24">
            <el-form-item>
              <el-button type="primary" @click="handleSaveButtonClick">保存图像</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
    <!-- 图像预览隐藏域 -->
    <el-dialog title="图像预览" :visible.sync="pageData.checkPanelStatus" size="tiny" width="480px"
               :before-close="handleCloseCheckPage">
      <el-card :body-style="{ padding: '0px' }">
        <div>
          <div>
            <img :src="pageData.checkPanelInfo" width="450px" height="450px">
          </div>
        </div>
      </el-card>
    </el-dialog>
  </div>
</template>

<script>
  // 组件引入
  // 方法工具引入
  import { PermissionsToDetectFormUser } from '@/utils/PermissionsDetect';
  import { getPermission } from '@/utils/UserCookies';
  // 接口引入
  import { loadCmsBannerList,saveCmsBannerData,saveBannerGroupData,batchReleaseCmsBannerData,updateCmsBannerData,deleteCmsBannerData } from "@/api/config";
  export default {
    name: "banner",
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
      return {
        pageData:{
          searchTypeList: [
            {label: "板块分类", value: -1},
            {label: "首页轮播图", value: 1},
            {label: "案例点评轮播图", value: 2},
            {label: "视频课堂轮播图", value: 3},
            {label: "研修直播直播广告", value: 4},
            {label: "问答板块轮播图", value: 5},
            {label: "发现板块轮播图", value: 6},
            {label: "滑动广告位", value: 98},
            {label: "Banner广告位", value: 99},
            {label: "App开机图", value: 9},
            {label: "报名广告(已废弃)", value: 21}
          ],
          searchStatusList: [
            {label: "发布状态", value: -1},
            {label: "发布", value: 1},
            {label: "下架", value: 0},
          ],
          searchJumpTypeList: [
            {label: "跳转类型", value: -1},
            {label: "内链", value: 0},
            {label: "外链", value: 1}
          ],
          loading: false,
          savePanelStatus: false,
          savePanelTitle: "",
          savePanelType: 0,
          bannerTypeList: [
            {label: "首页版块轮播图", value: 1},
            {label: "案例点评版块轮播图", value: 2},
            {label: "视频课堂版块轮播图", value: 3},
            {label: "研修直播版块直播广告图", value: 4},
            {label: "问答版块轮播图", value: 5},
            {label: "发现板块轮播", value: 6},
            {label: "公用滑动轮播广告", value: 98},
            {label: "Banner广告位", value: 99},
            {label: "APP开机图", value: 9},
            {label: "报名专属", value: 21}
          ],//
          bannerIsSubjectList: [
            {label: '广告内容', value: 0},
            {label: '单体内容', value: 1},
            {label: '套装内容', value: 2},
            {label: '专题内容', value: 3},
            {label: '问答内容', value: 4},
            {label: '活动内容', value: 5},
            {label: '在线课程', value: 6},
            {label: '在线报名', value: 7},
            {label: '小程序跳转', value: 8}
          ],
          checkPanelStatus: false,
          checkPanelInfo: "",
        },// 页面配置数据
        form:{
          searchTitle: "",
          searchType: -1,
          searchStatus: -1,
          searchJumpType: -1,
          pageNum: 1,
          pageSize: 12,
          total: 0,
          selection: [],
          banner: {
            id: "",
            bannerId: "",
            bannerType: 1,
            bannerImageType: 0,
            bannerIsOutLink: 0,
            bannerIsSubject: 0,
            bannerStatus: 0,
            bannerName: "",
            bannerImage: "",
            bannerArticleId: "",
            bannerJumpUrl: "",
            bannerInfo: "",
            bannerPicture: "",
            bannerSignUpId: "",
            bannerImageDuration: 0,
            startTime: "",
            endTime: "",
          }
        },// 页面表单
        formRules: {},// 表单验证
        responseData: {
          tableList: []
        },// 接口响应数据
      }
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods:{
      // 事件函数
      handlePageInit(){
        this.form.pageNum = 1;
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsBannerList();// 读取路由角色列表
      },// 页面初始化事件
      handleCurrentChange(val){
        this.form.pageNum = val;// 更换页码
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsBannerList();// 读取路由角色列表
      },// 页码切换事件
      handleSizeChange(val){
        this.form.pageSize = val;// 更换页面大小
        this.pageData.loading = true;// 创建加载窗口
        this.loadCmsBannerList();// 读取路由角色列表
      },// 页面size切换事件
      handleTableSelection(val){
        let list = [];// 初始化多选数组
        for (let i=0; i<val.length; i++){
          list.push(val[i].id);
        }// 遍历多选的列表，将ID拼入数组中
        this.form.selection = list;// 进行多选值的切换
      },// 表格多选事件
      handleOpenSavePage(){
        if (PermissionsToDetectFormUser(getPermission(), "520001")){
          // 初始化图集新增表单
          this.form.banner.bannerId = "";
          this.form.banner.bannerType = 1;
          this.form.banner.bannerImageType = 0;
          this.form.banner.bannerIsOutLink = 0;
          this.form.banner.bannerIsSubject = 0;
          this.form.banner.bannerStatus = 0;
          this.form.banner.bannerName = "";
          this.form.banner.bannerImage = "";
          this.form.banner.bannerArticleId = "";
          this.form.banner.bannerJumpUrl = "";
          this.form.banner.bannerInfo = "";
          this.form.banner.bannerPicture = "";
          this.form.banner.bannerSignUpId = "";
          this.form.banner.bannerImageDuration = 0;
          // 打开图集新增面板
          this.pageData.savePanelStatus = true;
          this.pageData.savePanelTitle = "新增图像";
          this.pageData.savePanelType = 1;
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 打开新增页面
      handleCloseSavePage(){
        this.$confirm("确认关闭？").then(response => {
          // 初始化图集新增表单
          this.form.banner.bannerId = "";
          this.form.banner.bannerType = 1;
          this.form.banner.bannerImageType = 0;
          this.form.banner.bannerIsOutLink = 0;
          this.form.banner.bannerIsSubject = 0;
          this.form.banner.bannerStatus = 0;
          this.form.banner.bannerName = "";
          this.form.banner.bannerImage = "";
          this.form.banner.bannerArticleId = "";
          this.form.banner.bannerJumpUrl = "";
          this.form.banner.bannerInfo = "";
          this.form.banner.bannerPicture = "";
          this.form.banner.bannerSignUpId = "";
          this.form.banner.bannerImageDuration = 0;
          // 打开图集新增面板
          this.pageData.savePanelStatus = false;
          this.pageData.savePanelTitle = "";
          this.pageData.savePanelType = 0;
        }).catch(err => {
          console.log(err);
        });
      },// 关闭新增面板
      handleBannerImageUploadSuccess(response){
        this.form.banner.bannerImage = response.data;
      },// ICON图上传成功
      handleBannerPictureUploadSuccess(response){
        this.form.banner.bannerPicture = response.data;
      },// 分享图上传成功
      handleSaveButtonClick(){
        // 新增面板保存数据按钮点击事件，验证用户是否有新增数据权限，保存数据
        if (this.pageData.savePanelType === 1 && (!PermissionsToDetectFormUser(getPermission(), "520001"))){
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
          return;
        }
        if (this.pageData.savePanelType === 2 && (!PermissionsToDetectFormUser(getPermission(), "520003"))){
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
          return;
        }
        if (this.form.banner.bannerType == 9){
          if (this.form.banner.startTime == "" || this.form.banner.endTime == "") {
            this.$message.warning('请输入开机图下架时间');
            return;
          }
        }
        this.$confirm('此操作将会保存当前数据, 请核对后继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // 进行网络请求
          if (this.pageData.savePanelType === 1) {
            this.saveCmsBannerData();
          } else if (this.pageData.savePanelType === 2) {
            this.updateCmsBannerData();
          }
        }).catch(close => {
          console.log(close);
          this.$message.info("已取消操作");
        });
      },// 保存按钮点击事件
      handleSaveBannerGroupButtonClick(){
        this.$confirm("当前操作将增加一组开机广告数据，请核对后确认?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.saveBannerGroupData();
        }).catch(close => {
          console.log(close);
          this.$message.info("已取消操作");
        });
      },// 新增开机图组点击事件
      handleBatchReleaseData(){
        if (PermissionsToDetectFormUser(getPermission(), "520005")){
          this.$confirm("是否发布当前所选数据?", "提示", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let param = {
              bannerId: this.form.selection.toString(),
              bannerStatus: 1
            };
            this.batchReleaseCmsBannerData(param);
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 批量发布数据
      handleCheckInfo(image){
        this.pageData.checkPanelStatus = true;
        this.pageData.checkPanelInfo = image;
      },// 预览图像
      handleCloseCheckPage(){
        this.$confirm("确认关闭？").then(response => {
          this.pageData.checkPanelStatus = false;
          this.pageData.checkPanelInfo = "";
        }).catch(err => {
          console.log(err);
        });
      },// 关闭预览页面
      handleOpenEditPage(scope){
        if (PermissionsToDetectFormUser(getPermission(), "520003")){
          // 初始化图集新增表单
          this.form.banner.id = scope.row.id;
          this.form.banner.bannerId = scope.row.id;
          this.form.banner.bannerType = scope.row.bannerType;
          this.form.banner.bannerImageType = scope.row.bannerImageType;
          this.form.banner.bannerIsOutLink = scope.row.bannerIsOutLink;
          this.form.banner.bannerIsSubject = scope.row.bannerIsSubject;
          this.form.banner.bannerStatus = scope.row.bannerStatus;
          this.form.banner.bannerName = scope.row.bannerName;
          this.form.banner.bannerImage = scope.row.bannerImage;
          this.form.banner.bannerArticleId = scope.row.bannerArticleId;
          this.form.banner.bannerJumpUrl = scope.row.bannerJumpUrl;
          this.form.banner.bannerInfo = scope.row.bannerInfo;
          this.form.banner.bannerPicture = scope.row.bannerPicture;
          this.form.banner.bannerSignUpId = scope.row.bannerSignUpId;
          this.form.banner.bannerImageDuration = scope.row.bannerImageDuration;
          // 打开图集新增面板
          this.pageData.savePanelStatus = true;
          this.pageData.savePanelTitle = "修改图像";
          this.pageData.savePanelType = 2;
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 打开修改页面板
      handleUpdateDataStatus(scope, status){
        if (PermissionsToDetectFormUser(getPermission(), "520005")){
          this.$confirm("是否更改当前所选数据的发布状态?", "提示", {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let param = {
              bannerId: scope.row.id,
              bannerStatus: status
            };
            this.batchReleaseCmsBannerData(param);
          }).catch(close => {
            console.log(close);
            this.$message.info("已取消操作");
          });
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 更改内容发布状态
      handleDeleteData(scope){
        if (PermissionsToDetectFormUser(getPermission(), "520002")){
          if (scope.row.bannerId === 21 || scope.row.bannerId === 22 || scope.row.bannerId === 0 ||
            scope.row.bannerId === 11 || scope.row.bannerId === 12 || scope.row.bannerId === 13){
            // 开机图组无法手动删除请联系管理员
            this.$message.info("开机图组无法手动删除请联系管理员");
          } else {
            this.$confirm('该操作将删除所选数据, 请核对后继续?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              let prams = {
                bannerId: scope.row.id
              };
              this.deleteCmsBannerData(prams);
            }).catch(close => {
              console.log(close);
              this.$message.info("已取消操作");
            });
          }
        } else {
          this.$message.warning('您的权限不足，无法使用此功能，请联系管理员');
        }
      },// 删除按钮点击事件
      // 接口
      loadCmsBannerList(){
        loadCmsBannerList(this.form).then(response => {
          if (response.code === "200"){
            this.pageData.loading = false;
            this.responseData.tableList = response.data.list;
            this.form.total = response.data.total;
          } else {
            this.$message.warning(response.message);
          }
        }).catch( error =>{
          console.log(error);
          this.$message.error(error);
        })
      },
      saveCmsBannerData(){
        saveCmsBannerData(this.form.banner).then(response => {
          if (response.code === "200"){
            this.$message.success("保存成功");
            // 初始化图集新增表单
            this.form.banner.bannerId = "";
            this.form.banner.bannerType = 1;
            this.form.banner.bannerImageType = 0;
            this.form.banner.bannerIsOutLink = 0;
            this.form.banner.bannerIsSubject = 0;
            this.form.banner.bannerStatus = 0;
            this.form.banner.bannerName = "";
            this.form.banner.bannerImage = "";
            this.form.banner.bannerArticleId = "";
            this.form.banner.bannerJumpUrl = "";
            this.form.banner.bannerInfo = "";
            this.form.banner.bannerPicture = "";
            this.form.banner.bannerSignUpId = "";
            this.form.banner.bannerImageDuration = 0;
            // 打开图集新增面板
            this.pageData.savePanelStatus = false;
            this.pageData.savePanelTitle = "";
            this.pageData.savePanelType = 0;
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 保存图集数据
      saveBannerGroupData(){
        saveBannerGroupData().then(response => {
          if (response.code === "200"){
            this.$message.success("保存成功");
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 保存开机图组
      batchReleaseCmsBannerData(param){
        batchReleaseCmsBannerData(param).then(response => {
          if (response.code === "200"){
            this.$message.success(param.bannerStatus === 1 ? "发布成功" : "下架成功");
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(close => {
          console.log(close);
        });
      },// 批量发布数据
      updateCmsBannerData(){
        updateCmsBannerData(this.form.banner).then(response => {
          if (response.code === "200"){
            this.$message.success("保存成功");
            // 初始化图集新增表单
            this.form.banner.bannerId = "";
            this.form.banner.bannerType = 1;
            this.form.banner.bannerImageType = 0;
            this.form.banner.bannerIsOutLink = 0;
            this.form.banner.bannerIsSubject = 0;
            this.form.banner.bannerStatus = 0;
            this.form.banner.bannerName = "";
            this.form.banner.bannerImage = "";
            this.form.banner.bannerArticleId = "";
            this.form.banner.bannerJumpUrl = "";
            this.form.banner.bannerInfo = "";
            this.form.banner.bannerPicture = "";
            this.form.banner.bannerSignUpId = "";
            this.form.banner.bannerImageDuration = 0;
            // 打开图集新增面板
            this.pageData.savePanelStatus = false;
            this.pageData.savePanelTitle = "";
            this.pageData.savePanelType = 0;
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      },// 更新图集数据
      deleteCmsBannerData(prams){
        deleteCmsBannerData(prams).then(response => {
          if (response.code === "200"){
            this.$message.success("删除成功");
            this.handlePageInit();
          } else {
            this.$message.warning(response.message);
          }
        }).catch(error => {
          console.log(error);
          this.$message.error(error);
        })
      }// 删除图集数据
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created: function () {
      let _this = this;
      document.onkeydown = function(e) {
        if (!_this.pageData.loading) {
          let key = window.event.keyCode;
          if (key === 13) {
            _this.handlePageInit(); //此方法是当按下enter键后要做的动作。
          }
        }
      };
      setTimeout(function () {
        _this.handlePageInit();
      }, 800);
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
    beforeCreate() {}, //生命周期 - 创建之前
    beforeMount() {}, //生命周期 - 挂载之前
    beforeUpdate() {}, //生命周期 - 更新之前
    updated() {}, //生命周期 - 更新之后
    beforeDestroy() {}, //生命周期 - 销毁之前
    destroyed() {}, //生命周期 - 销毁完成
    activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
  };
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
